package com.atguigu.dao.impl;

import com.atguigu.dao.UpdateTomcatCodeAndHeartbeatTaskDao;
import com.atguigu.pojo.UpdateTomcatCodeAndHeartbeatTask;

import java.util.List;


public class UpdateTomcatCodeAndHeartbeatTaskDaoImpl extends BaseDao implements UpdateTomcatCodeAndHeartbeatTaskDao {

    @Override
    public int addUpdateTomcatCodeAndHeartbeatTask(UpdateTomcatCodeAndHeartbeatTask updateTomcatCodeAndHeartbeatTask) {
        System.out.println("UpdateTomcatCodeAndHeartbeatTaskDaoImpl程序在[" + Thread.currentThread().getName() + "]线程中");
        String sql = "insert into t_updateTomcatCodeAndHeartbeatTask(`id`,`name`,`file`,`projectType`,`projectModule`,`status`) values(?,?,?,?,?,?);";
        return update(sql,updateTomcatCodeAndHeartbeatTask.getId(), updateTomcatCodeAndHeartbeatTask.getName(),updateTomcatCodeAndHeartbeatTask.getFile(),updateTomcatCodeAndHeartbeatTask.getProjectType(),updateTomcatCodeAndHeartbeatTask.getProjectModule(),updateTomcatCodeAndHeartbeatTask.getStatus());
    }

    @Override
    public int deleteUpdateTomcatCodeAndHeartbeatTaskById(String id) {
        String sql = "delete from t_updateTomcatCodeAndHeartbeatTask where id=?";
        return update(sql, id);
    }

    @Override
    public int updateUpdateTomcatCodeAndHeartbeatTask(UpdateTomcatCodeAndHeartbeatTask updateTomcatCodeAndHeartbeatTask) {
        String sql = "update t_updateTomcatCodeAndHeartbeatTask set `name`=?,`file`=?,`projectType`=?,`projectModule`=?,`status`=? where id=?";
        return update(sql, updateTomcatCodeAndHeartbeatTask.getName(),updateTomcatCodeAndHeartbeatTask.getFile(),updateTomcatCodeAndHeartbeatTask.getProjectType(),updateTomcatCodeAndHeartbeatTask.getProjectModule(),updateTomcatCodeAndHeartbeatTask.getStatus(), updateTomcatCodeAndHeartbeatTask.getId());
    }

    @Override
    public UpdateTomcatCodeAndHeartbeatTask queryUpdateTomcatCodeAndHeartbeatTaskById(String id) {
        String sql = "select `id`,`name`,`file`,`projectType`,`projectModule`,`status` from t_updateTomcatCodeAndHeartbeatTask where id=?";
        return queryForOne(UpdateTomcatCodeAndHeartbeatTask.class, sql, id);
    }

    @Override
    public List<UpdateTomcatCodeAndHeartbeatTask> queryUpdateTomcatCodeAndHeartbeatTasks() {// 查询全部
        String sql = "select `id`,`name`,`file`,`projectType`,`projectModule`,`status` from t_updateTomcatCodeAndHeartbeatTask";
        return queryForList(UpdateTomcatCodeAndHeartbeatTask.class, sql);
    }

    @Override
    public Integer queryForPageTotalCount() {//查询总条目数,为page分片做准备
        String sql = "select count(*) from t_updateTomcatCodeAndHeartbeatTask";
        Number updateTomcatCodeAndHeartbeatTaskCount = (Number) queryForSingleValue(sql);//这个语句似乎可以返回任何类型的查询
        //System.out.println(bookCount);
        return updateTomcatCodeAndHeartbeatTaskCount.intValue();
    }

    @Override
    public List<UpdateTomcatCodeAndHeartbeatTask> queryForPageItems(Integer begin, Integer pageSize) {
        String sql = "select `id`,`name`,`file`,`projectType`,`projectModule`,`status` from t_updateTomcatCodeAndHeartbeatTask limit ?,?";
        return queryForList(UpdateTomcatCodeAndHeartbeatTask.class, sql, begin, pageSize);//查询数据片段
    }
}


